Skip to content

Ensure correct SPN when calling SspiContextProvider #3347

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 24 commits into from
Jul 15, 2025

Conversation

twsouthwick
Copy link
Member

@twsouthwick twsouthwick commented May 14, 2025

This change does the following:

  • Only initialize when handshake is complete
  • The serverSpn field is now local to the method
  • Adds some bookkeeping to ensure we're only using the SPN that has previously generated a context once one has been created.
  • Reworks the SNI pathways on .NET Core to only return the SPN that is needed. On .NET Core, it was returning an array but only using a single value from that. This refactors that to be more readable to just return the value used.

See comment: See #2454 (comment)

Part of #2253

@twsouthwick twsouthwick force-pushed the reset-negotiate branch 2 times, most recently from 5610fa9 to 6ee0ae5 Compare May 15, 2025 18:11
@twsouthwick twsouthwick requested a review from a team as a code owner May 15, 2025 18:11
This change also adds some book keeping to ensure we're only using the spn that has previously generated a context once one has been created.
Copy link

codecov bot commented May 16, 2025

Codecov Report

Attention: Patch coverage is 75.47170% with 13 lines in your changes missing coverage. Please review.

Project coverage is 58.88%. Comparing base (8eb9f32) to head (acc7602).
Report is 11 commits behind head on main.

Files with missing lines Patch % Lines
...crosoft/Data/SqlClient/SSPI/SspiContextProvider.cs 73.68% 5 Missing ⚠️
...nt/netfx/src/Microsoft/Data/SqlClient/TdsParser.cs 50.00% 3 Missing ⚠️
...ata/SqlClient/SSPI/NegotiateSspiContextProvider.cs 70.00% 3 Missing ⚠️
.../netcore/src/Microsoft/Data/SqlClient/TdsParser.cs 80.00% 1 Missing ⚠️
...soft/Data/SqlClient/ManagedSni/SniProxy.netcore.cs 80.00% 1 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (8eb9f32) and HEAD (acc7602). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (8eb9f32) HEAD (acc7602)
addons 1 0
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3347      +/-   ##
==========================================
- Coverage   68.86%   58.88%   -9.98%     
==========================================
  Files         280      271       -9     
  Lines       62417    61907     -510     
==========================================
- Hits        42982    36457    -6525     
- Misses      19435    25450    +6015     
Flag Coverage Δ
addons ?
netcore 67.37% <78.72%> (-5.38%) ⬇️
netfx 63.81% <72.41%> (-4.23%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

@paulmedynski paulmedynski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments about handling multipe and single SPNs.

Copy link
Contributor

@paulmedynski paulmedynski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops - hit Comment instead of Request Changes

paulmedynski
paulmedynski previously approved these changes May 16, 2025
paulmedynski
paulmedynski previously approved these changes May 26, 2025
@paulmedynski
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@paulmedynski
Copy link
Contributor

@twsouthwick - Did you have to resolve any conflicts from your previous commits when merging main? It's hard to tell from the large merge commit.

@twsouthwick
Copy link
Member Author

@paulmedynski I did have to resolve a couple of things - mostly that I had added a type into the SNI directory, and it has been renamed to ManagedSni. I did the merge resolution on GH and hadn't built locally... I've pushed a fix that should succeed

@paulmedynski paulmedynski added this to the 6.1.0 milestone Jul 14, 2025
paulmedynski
paulmedynski previously approved these changes Jul 14, 2025
@paulmedynski
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 2 pipeline(s).

mdaigle
mdaigle previously approved these changes Jul 14, 2025
@twsouthwick twsouthwick dismissed stale reviews from mdaigle and paulmedynski via acc7602 July 14, 2025 21:13
@paulmedynski
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@paulmedynski paulmedynski requested a review from mdaigle July 15, 2025 14:50
@twsouthwick
Copy link
Member Author

@mdaigle fixed a merge error that only failed on a few builds so it's ready now :) thanks for all the feedback!

@mdaigle mdaigle merged commit 42146a3 into dotnet:main Jul 15, 2025
237 checks passed
mdaigle pushed a commit that referenced this pull request Jul 15, 2025
* Reset negotiateAuth if SNI doesn't work

This change also adds some book keeping to ensure we're only using the spn that has previously generated a context once one has been created.

* initialization only after success

* move serverSpn to be local
@paulmedynski paulmedynski modified the milestones: 6.1.0, 7.0-preview1 Jul 15, 2025
@twsouthwick twsouthwick deleted the reset-negotiate branch July 15, 2025 16:36
benrr101 pushed a commit that referenced this pull request Jul 15, 2025
* Reset negotiateAuth if SNI doesn't work

This change also adds some book keeping to ensure we're only using the spn that has previously generated a context once one has been created.

* initialization only after success

* move serverSpn to be local

Co-authored-by: Taylor Southwick <tasou@microsoft.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants